package com.lyh.notes.mapper;


import com.lyh.notes.model.dto.user.UserQueryParam;
import com.lyh.notes.model.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface UserMapper {
    public User findUserByAccount(String account);

    public User findUserByEmail(String email);

    int insert(User newUser);

    int updateLastLoginAt(Long userId);

    User findUserById(Long userId);

    int updateUserInfo(User user);

    int countByQueryParam(@Param("queryParams") UserQueryParam queryParams);

    List<User> findByQueryParam(@Param("queryParams") UserQueryParam queryParams,
                                @Param("limit") Integer limit,
                                @Param("offset") Integer offset);


    List<User> findUserByIdBatch(@Param("userIds")List<Long> usersId);

    List<User> searchUsers(@Param("keyword") String keyword,
                           @Param("limit") int limit,
                           @Param("offset") int offset);

    void updateAvatar(String url);

    void updateAvatar(@Param("url") String url, @Param("userId") Long userId);

    int deleteUser(@Param("userId") Long userId);

    int countByKeyword(@Param("keyword") String keyword);
}
